export default {
	namespaced: true,
	state: {
		address: uni.getStorageSync('address') || {},
		// 登录的标识
		token: uni.getStorageSync('token') || '',
		// 用户信息
		userInfo: uni.getStorageSync('userInfo') || {},
		// 保存跳转到之前的页面信息
		redirectInfo: {}
	},
	mutations: {
		setAddress(state, address) {
			state.address = address
			uni.setStorageSync('address', state.address)
		},
		// 用来保存用户信息
		setUserInfo(state, userInfo) {
			// 保存到 vuex 中
			state.userInfo = userInfo
			// 保存到 storeage 中
			uni.setStorageSync('userInfo', state.userInfo)
		},
		// 保存 token
		setToken(state, token) {
			state.token = token
			// 保存到本地
			uni.setStorageSync('token', token)
		},
		logout1(state) {
			console.log(2232323);
			// 清除 token
			state.token = ''
			uni.setStorageSync('token', '')
			// 清除 userInfo
			state.userInfo = {}
			uni.setStorageSync('userInfo', {})
			// 清除address
			state.address = {}
			uni.setStorageSync('address', {})
		},
		setRedirectInfo(state, info) {
			// 将数据保存到 vuex 中
			state.redirectInfo = info
			// 不需要将数据保存到本地
		}
	},
	actions: {},
	getters: {
		// 详细地址
		fullAddress: function(state) {
			return state.address.provinceName + state.address.cityName + state.address.countyName + state.address
				.detailInfo
		}
	}
}
